package com.spirng.leetcode.day07;

public class Test538 {
    int a=1;
    TreeNode pre;
    int res=0;
    public TreeNode convertBST(TreeNode root) {
        if(root==null){
            return null;
        }
        TreeNode right=convertBST(root.right);
        if(pre!=null){
            root.val += pre.val;
        }
        pre=root;
        convertBST(root.left);
        return root;
    }
}
